﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
using WebPortal.Models.EntityModels;

namespace WebPortal.Models.ViewModel
{
    public class UserDetailsModel
    {
        [StringLength(40, ErrorMessage = "Must be less than 40 letters")]
        public string ContactName { get; set; }

        [StringLength(10, ErrorMessage = "Must be less than 10 letters")]
        public string PostalCode { get; set; }

        [StringLength(60, ErrorMessage = "Must be less than 60 letters")]
        public string Address { get; set; }

        [StringLength(30, ErrorMessage = "Must be less than 30 letters")]
        public string City { get; set; }

        [StringLength(20, ErrorMessage = "Must be less than 20 letters")]
        public string Country { get; set; }

        [StringLength(24, ErrorMessage = "Must be less than 24 letters")]
        public string Phone { get; set; }

        [StringLength(24, ErrorMessage = "Must be less than 24 letters")]
        public string Fax { get; set; }

        public UserDetailsModel() {}

        public UserDetailsModel(Users u)
        {
            ContactName = u.ContactName;
            PostalCode = u.PostalCode;
            Address = u.Address;
            City = u.City;
            Country = u.Country;
            Phone = u.Phone;
            Fax = u.Fax;
        }

        public void CopyToUser(ref Users u)
        {
            u.ContactName = ContactName;
            u.PostalCode = PostalCode;
            u.Address = Address;
            u.City = City;
            u.Country = Country;
            u.Phone = Phone;
            u.Fax = Fax;
        }
    }
}